<template>
  <div class="payment-success">
    <div class="success-container">
      <div class="success-icon">
        <i class="el-icon-success"></i>
      </div>
      <h2>支付成功</h2>
      <div class="payment-info">
        <p>订单号：{{ orderNo }}</p>
        <p>交易号：{{ tradeNo }}</p>
        <p>支付金额：¥{{ amount }}</p>
      </div>
      <div class="action-buttons">
        <el-button type="primary" @click="goToOrderDetail">查看订单</el-button>
        <el-button @click="goToHome">返回首页</el-button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "PaymentSuccess",
  data() {
    return {
      orderNo: "",
      tradeNo: "",
      amount: "",
    };
  },
  created() {
    // 从URL参数中获取支付信息
    const query = this.$route.query;
    this.orderNo = query.out_trade_no;
    this.amount = query.total_amount;
    this.tradeNo = query.trade_no;
  },
  methods: {
    goToOrderDetail() {
      this.$router.push("/order");
    },
    goToHome() {
      this.$router.push("/");
    },
  },
};
</script>

<style scoped>
.payment-success {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background-color: #f5f5f5;
}

.success-container {
  background: white;
  padding: 40px;
  border-radius: 8px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  text-align: center;
}

.success-icon {
  font-size: 48px;
  color: #67c23a;
  margin-bottom: 20px;
}

.payment-info {
  margin: 20px 0;
  text-align: left;
}

.payment-info p {
  margin: 10px 0;
  color: #666;
}

.action-buttons {
  margin-top: 30px;
}

.action-buttons .el-button {
  margin: 0 10px;
}
</style>